const btn = document.querySelector('.btn');

const transform = files => {
    if (files.length !== 0) {
        Array.prototype.forEach.call(files, file => {
            const fileReader = new FileReader();
            fileReader.onload = res => {
                // 保存成文件
                saveAs(
                    new Blob([res.target.result], { type: "text/plain;charset=utf-8" }), 
                    file.name+'.txt'
                )
            }
            fileReader.readAsDataURL(file)
        })
    }
}

btn.addEventListener('click', () => {
    const input = document.querySelector('#fileEl');

    if (input.files.length !== 0) {
        transform(input.files)
    }
})